package com.itheima;

public class User {
    private String userName;
    private String sex;
    private String ip;
    private int age;


    public User() {
    }

    public User(String userName, String sex, String ip, int age) {
        this.userName = userName;
        this.sex = sex;
        this.ip = ip;
        this.age = age;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String toString() {
        return "User{userName = " + userName + ", sex = " + sex + ", ip = " + ip + ", age = " + age + "}";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        User user = (User) o;

        if (age != user.age) return false;
        if (userName != null ? !userName.equals(user.userName) : user.userName != null) return false;
        if (sex != null ? !sex.equals(user.sex) : user.sex != null) return false;
        return ip != null ? ip.equals(user.ip) : user.ip == null;
    }

    @Override
    public int hashCode() {
        int result = userName != null ? userName.hashCode() : 0;
        result = 31 * result + (sex != null ? sex.hashCode() : 0);
        result = 31 * result + (ip != null ? ip.hashCode() : 0);
        result = 31 * result + age;
        return result;
    }
}
